from collections import Iterable


def flatten(items,ignore_types=(str,bytes)):
    for x in items:
        if isinstance(x,Iterable) and not isinstance(x, ignore_types):
            yield from flatten(x)
        else:
            yield x

def flatten1(items, ignore_types=(str, bytes)):
    for x in items:
        if isinstance(x, Iterable) and not isinstance(x, ignore_types):
            for i in flatten1(x):
                yield i
        else:
            yield x

if __name__ == '__main__':
    items = [1, 2, [3, 4, [5, [6.1,6]], 7], 8]
    for x in flatten1(items):
        print(x)